<template>
	<el-form-item
		v-if="prtot && prop"
		:prop="`${prtot}.${prop}`"
		:rules="[
			{
				required: true,
				message: '不能为空',
				trigger: 'change'
			}
		]"
	>
		<!-- {{ `${prtot}.${prop}` }} -->
		<el-input-number
			:value="value"
			:controls="false"
			:min="-9999999999.99"
			:max="9999999999.99"
			:step="0.01"
			step-strictly
			class="num-input"
			@change="handleChange"
		/>
	</el-form-item>
</template>
<script>
export default {
  props: {
    scope: {
      type: Object,
      default: {}
    },
    updateData: {
      type: Function,
      default: () => { }
    },
    name: {
      type: String,
      default: ''
    }
  },
  computed: {
    prtot() {
      const { row } = this.scope
      return row.name
    },
    prop() {
      if (this.name) {
        return this.name
      }
      const { column, row } = this.scope
      const __prefix = row.__prefix || ''
      return `${__prefix}${column.property}`
    },
    value() {
      const { row } = this.scope
      return row[this.prop]
    }
  },
  methods: {
    handleChange(newVal) {
      this.updateData(newVal, this.prop)
    }
  }
}

</script>

<style scoped>
.num-input{
	width: 120px;
}
</style>

